
<?php
 //  Просмотр страниц отображения статей ______________________________________________________________
 
    $connection = connect($config);
 
if(isset($_GET['page']) && $_GET['jurist'] == 'article'){

    $articlres = getAllPosts($connection, "SELECT * FROM article WHERE `redaction` = 1");         
    $allcount = count($articlres);
 
    $limit1 = 0;
    $limit2 = 4; 
    
        echo "<div class='numeration'>";
         if ($allcount > 4)
        {
            $pagestr = $allcount / 4;
            $pagestr = ceil($pagestr);
   
            for ($i = 1;$i <= $pagestr;$i++)
            {
            echo "<a href='/jurist/article&page=".$i."'> $i </a>";
            }
        }
        echo "</div>";
        
    $getstr = $_GET['page'];
 
    for ($g = 1; $g < $getstr; $g++)
    {
        $limit1 = $limit1 + 4;
    }
    $articlres = getAllPosts($connection, "SELECT * 
                                            FROM  `article` 
                                            ORDER BY  `article`.`ArticleID` DESC 
                                            LIMIT $limit1 , $limit2");
 
 
    $countart = count($articlres);
 
 
    for ($i = 0;$i < $countart; $i++)
    {
    
        $s1 = mb_substr($articlres[$i][Article],0,500,'utf-8');
        
        $s2 =  strlen($articlres[$i][Article]);
        
        echo "<h3 class='articltitle'><a href='/jurist/article&articl=".$articlres[$i][ArticleID]."'>".$articlres[$i][ArticlTitle]."</a></h3>";
    
        echo "<p>".$s1;
        if($s2 > 500) echo ".....";
        echo "</p>";
        
        if($s2 > 500) echo "<span class='articleright'><a href='/jurist/article&articl=".$articlres[$i][ArticleID]."'>Читать дальше ></a></span>";

    
    }
} 
 
// Просмотр самой статьи __________________________________________

    if(isset($_GET['articl']))
    {
         $getID = array('id' => $_GET['articl']);
         $articlres = query("SELECT * FROM article WHERE `ArticleID` = :id", $getID, $connection);

    echo "<h3 class='articltitle'>".$articlres[0][ArticlTitle]."</h3>";
    echo "<p><span>".$articlres[0][CreateDate]."</span></p>";
    echo "<p><span>".$articlres[0][Article]."</span></p>";   
    }



 
	  
?>